package com.zhuzhumail.utils;

import cn.hutool.core.util.StrUtil;

import java.util.Calendar;

/**
 * 日期枚举
 */
public enum DateEnum {

    MONDAY("星期一", "MONDAY", Calendar.MONDAY),
    TUESDAY("星期二", "TUESDAY", Calendar.TUESDAY),
    WEDNESDAY("星期三", "WEDNESDAY", Calendar.WEDNESDAY),
    THURSDAY("星期四", "THURSDAY", Calendar.THURSDAY),
    FRIDAY("星期五", "FRIDAY", Calendar.FRIDAY),
    SATURDAY("星期六", "SATURDAY", Calendar.SATURDAY),
    SUNDAY("星期日", "SUNDAY", Calendar.SUNDAY);

    private String date;
    private String dateEnglish;
    private int calendarKey;

    DateEnum(String date, String dateEnglish, int calendarKey) {
        this.date = date;
        this.dateEnglish = dateEnglish;
        this.calendarKey = calendarKey;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getDateEnglish() {
        return dateEnglish;
    }

    public void setDateEnglish(String dateEnglish) {
        this.dateEnglish = dateEnglish;
    }

    public int getCalendarKey() {
        return calendarKey;
    }

    public void setCalendarKey(int calendarKey) {
        this.calendarKey = calendarKey;
    }

    public static String Dateequer(String aa) {
        DateEnum[] values = DateEnum.values();
        for (DateEnum dateEnum : values) {
            if (dateEnum.getDateEnglish().equals(aa)) {
                return dateEnum.getDate();
            }
        }
        return null;
    }

    /**
     * 通过枚举<code>code</code>获取枚举
     *
     * @param dateEnglish
     * @return
     */
    public static DateEnum getEnumByDateEnglish(String dateEnglish) {
        for (DateEnum dateEnum : DateEnum.values()) {
            if (StrUtil.equals(dateEnum.getDateEnglish(), dateEnglish)) {
                return dateEnum;
            }
        }
        return null;
    }

    /**
     * 通过枚举<code>calendarKey</code>获取枚举
     *
     * @param calendarKey
     * @return
     */
    public static DateEnum getEnumByCode(int calendarKey) {
        for (DateEnum dateEnum : DateEnum.values()) {
            if (calendarKey == dateEnum.getCalendarKey()) {
                return dateEnum;
            }
        }
        return null;
    }
}
